package java6681.truck;

class Truck6681{
    private double speed;
    private int power;
    public void setPower(int power){
        this.power = power;
        System.out.println(this.power);
    }
    public int getPower(){
        return power;
    }
    public void setSpeed(double speed){
        this.speed = speed;
    }
    public double getSpeed(){
        return speed;
    }
    public void speedUp(int speed){
        if (speed + this.speed <= 160) {
            this.speed += speed;
            System.out.println(speed);
        } else{
            System.out.println("超速");
            }
        }
    public void speedDown(int speed){
        if (speed >= this.speed){
            System.out.println("减速过多");
        }else{
            this.speed-=speed  ;
            System.out.println(this.speed);
        }
    }
    public void brake(){
        speed = 0;
        System.out.println(speed);
    }
}
public class UseTruck6681 {
    public static void main(String[] args) {
        Truck6681 truct1 = new Truck6681();
        truct1.setPower(150);
        truct1.speedUp(100);
        truct1.speedDown(10);
        truct1.speedUp(150);
        truct1.speedDown(300);
        truct1.speedUp(90);
        truct1.brake();
    }
}
